%% Licensed to the Apache Software Foundation (ASF) under one
%% or more contributor license agreements.  See the NOTICE file
%% distributed with this work for additional information
%% regarding copyright ownership.  The ASF licenses this file
%% to you under the Apache License, Version 2.0 (the
%% "License"); you may not use this file except in compliance
%% with the License.  You may obtain a copy of the License at
%%
%%   http://www.apache.org/licenses/LICENSE-2.0
%%
%% Unless required by applicable law or agreed to in writing,
%% software distributed under the License is distributed on an
%% "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
%% KIND, either express or implied.  See the License for the
%% specific language governing permissions and limitations
%% under the License.

sequenceDiagram
    Note over Airflow Repo: scheduled
    Note over CI Build: schedule<br>[Write Token]
    Note over Build Images: schedule<br>[Write Token]
    activate Airflow Repo
    Airflow Repo -->> CI Build: Trigger 'schedule'
    activate CI Build
    Airflow Repo -->> Build Images: Trigger 'schedule'
    activate Build Images
    Note over Build Images: Build info
    par 3.6, 3.7, 3.8, 3.9
        Note over Build Images: Build CI Images<br>Cache disabled<br>[COMMIT_SHA]
    end
    par No CI image
        Note over CI Build: Build info<br>All tests<br>All python
    and
        Note over CI Build: OpenAPI client gen
    and
        Note over CI Build: Test UI
    and
        Note over CI Build: Test examples<br>PROD image building
    end
    par 3.6, 3.7, 3.8, 3.9
        Build Images ->> GitHub Registry: Push CI Images
        activate GitHub Registry
        Note over GitHub Registry: Tagged CI Images<br>[COMMIT_SHA]
    end
    par 3.6, 3.7, 3.8, 3.9
        Note over Build Images: Build PROD Images<br>Cache disabled<br>[COMMIT_SHA]
    end
    loop Wait for CI images
        par 3.6, 3.7, 3.8, 3.9
            CI Build ->> CI Build: Check CI Images
            Note over CI Build: Wait for<br>[COMMIT_SHA]
        end
    end
    par 3.6, 3.7, 3.8, 3.9
        GitHub Registry ->> CI Build: Pull CI Image [COMMIT_SHA]
        Note over CI Build: Verify CI Image
    end
    deactivate GitHub Registry
    par 3.6, 3.7, 3.8, 3.9
        Note over CI Build: Run static checks
    and
        Note over CI Build: Build docs
    and
        Note over CI Build: Tests
    and
        Note over CI Build: Test provider <br>packages build
    and
        Note over CI Build: Helm tests
    end
    par 3.6, 3.7, 3.8, 3.9
        Build Images ->> GitHub Registry: Push PROD Images
        activate GitHub Registry
        Note over GitHub Registry: Tagged PROD Images<br>[COMMIT_SHA]
    end
    deactivate Build Images
    loop Wait for PROD images
        par 3.6, 3.7, 3.8, 3.9
            CI Build ->> CI Build: Check PROD Images
            Note over CI Build: Wait for<br>[COMMIT_SHA]
        end
    end
    par 3.6, 3.7, 3.8, 3.9
        GitHub Registry ->> CI Build: Pull PROD Image [COMMIT_SHA]
        Note over CI Build: Verify PROD Image
    end
    deactivate GitHub Registry
    par 3.6, 3.7, 3.8, 3.9
        Note over CI Build: Run Kubernetes <br>tests
    and
        Note over CI Build: Run Kubernetes <br>upgrade tests
    end
    par 3.6, 3.7, 3.8, 3.9
        Note over CI Build: Generate constraints
        CI Build ->> Airflow Repo: Push constraints
    end
    CI Build -->> Airflow Repo: Status update
    deactivate Airflow Repo
    deactivate CI Build
